

package edu.wfu.preparedDishes.user.config;

import edu.wfu.preparedDishes.user.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 拦截器配置类
 */


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(jwtInterceptor())
               .addPathPatterns("/**")
               .excludePathPatterns("/websocket/**")
                .excludePathPatterns("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-resources/configuration/ui", "/swagger-resources/configuration/security", "/swagger-resources/configuration/security")
                .excludePathPatterns("/user/user/login");
    }
}

